#include <bits/stdc++.h>
using namespace std;
int n;
const int maxn = 200000 + 10;
const int INF = 1e9 + 7;
int c[maxn], d[maxn];
int pre[maxn];
bool existA = false, existB = false;
int main() {
  int Amin = INF, Bmax = -INF;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> c[i] >> d[i];
    pre[i] = pre[i - 1] + c[i];
    d[i]--;  // 0 = A, 1 = B
    if (d[i]) {
      existB = true;
      // Bmax = min(Bmax, pre[i]);
    } else {
      existA = true;
      // Amin = min(Amin, pre[i]);
    }
  }
  if (!(existB)) {
    cout << "Infinity\n";
    return 0;
  }
  for (int i = 1; i < n; ++i) {
    if (d[i] && !d[i + 1]) {  // B -> A
      if (c[i] <= 0) {
        cout << "Impossible\n";
        return 0;
      }
    }
    if (!d[i] && d[i + 1]) {  // A -> B
      if (c[i] >= 0) {
        cout << "Impossible\n";
        return 0;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (d[i])
      Bmax = max(Bmax, pre[i - 1]);
    else
      Amin = min(Amin, pre[i - 1]);
  }
  // for (int i = 0; i <= n; ++i) cout << pre[i] << ' ';
  // cout << endl;
  // cout << Amin << ' ' << Bmax << endl;

  if (Amin <= Bmax) {
    cout << "Impossible\n";
  } else {
    cout << 1899 - (Bmax) + pre[n] << '\n';
  }

  // for (int i = 0; i <= n; ++i) cout << c[i] << ' ' << pre[i] << endl;
}
